
import 'dart:mirrors';
import 'package:flutter_03_dart/lib.dart';


void refClass(){

  //currentMirrorSystem  当前所有依赖到当前工程内的所有lib

  var libMirror = currentMirrorSystem();
  LibraryMirror findLibrary = libMirror.findLibrary(Symbol('lib.pkg'));
  findLibrary.declarations.forEach((key, value) => print("LibraryMirror:$key | $value"));



  ClassMirror classMirror = findLibrary.declarations[Symbol('Person')] as ClassMirror;

  var instance = classMirror.newInstance(Symbol.empty, ["zhangsan",18]);
  instance.reflectee.printer();
  print(instance.reflectee.name);


  // print(findLibrary);
  // findLibrary.declarations.forEach((s, d) => print(s));
  // ClassMirror? classMirror = findLibrary.declarations[Symbol("Person")] as ClassMirror;
  // classMirror.declarations.forEach((s, d) => print("classMirror:$s"));

  // var instance = classMirror.newInstance(Symbol.empty ,["张三",18]);

  //属性
  // print(instance.reflectee.name);
  // print(instance.reflectee.age);

  //方法
  // instance.reflectee.printer();
}

void main(){
  refClass();


}